Class Release

  • Direct Known Subclasses:
    Album, MusicVideo

    public abstract class Release
    extends java.lang.Object
    This class represents a release of a specific artist, like an album or a music video.
    Since:
    ExerciseSheet04
    Version:
    1
    Author:
    Jonas Altrock (ew20b126@technikum-wien.at)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Artist artist
      The artist that released this release.
      A null artist represents an unknown artist.
      private java.lang.String title
      The title of this release.
      A null title represents an unknown title.
      private int year
      The year in which this release was released.
      The year cannot be negative, value 0 (zero) representing unknown year.
    • Constructor Summary

      Constructors 
      Constructor Description
      Release()
      Creates a default release.
      A default release has default values for all fields (see there).
      Release​(java.lang.String title, Artist artist, int year)
      Create a release with a specific title of a specific artist in a specific year.
      Release​(Release r)
      Creates a copy of a release.
      This release is a deep copy of an existing release - the original.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      Artist getArtist()
      Get the artist of this release.
      java.lang.String getTitle()
      Get the title of this release.
      If the title is unknown a null String is returned.
      int getYear()
      Get the year in which this release was released.
      void setArtist​(Artist artist)
      Set the artist of this release.
      This method accepts null arguments.
      void setTitle​(java.lang.String title)
      Set the title of this release.
      This method accepts null Strings.
      void setYear​(int year)
      Set the year of this release.
      If the argument is outside the allowed range it is ignored.
      java.lang.String toString()
      Get a textual representation of this release.
      abstract int totalTime()
      Get the total time of this release.
      The implementation of this method is left to concrete subclasses.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • artist

        private Artist artist
        The artist that released this release.
        A null artist represents an unknown artist. By default, it is the default artist.
      • year

        private int year
        The year in which this release was released.
        The year cannot be negative, value 0 (zero) representing unknown year. By default, the year is 1900.
      • title

        private java.lang.String title
        The title of this release.
        A null title represents an unknown title. The default title is unknown.
    • Constructor Detail

      • Release

        public Release()
        Creates a default release.
        A default release has default values for all fields (see there).
      • Release

        public Release​(Release r)
        Creates a copy of a release.
        This release is a deep copy of an existing release - the original.
        Parameters:
        r - the release to be copied
      • Release

        public Release​(java.lang.String title,
                       Artist artist,
                       int year)
        Create a release with a specific title of a specific artist in a specific year.
        Parameters:
        title - the title of the new release
        artist - the artist of the new release
        year - the year of the new release
    • Method Detail

      • getTitle

        public java.lang.String getTitle()
        Get the title of this release.
        If the title is unknown a null String is returned.
        Returns:
        the title
      • setTitle

        public void setTitle​(java.lang.String title)
        Set the title of this release.
        This method accepts null Strings.
        Parameters:
        title - the title to set
      • getArtist

        public Artist getArtist()
        Get the artist of this release.
        Returns:
        the artist of this release.
      • setArtist

        public void setArtist​(Artist artist)
        Set the artist of this release.
        This method accepts null arguments.
        Parameters:
        artist - the artist to set.
      • getYear

        public int getYear()
        Get the year in which this release was released.
        Returns:
        the year of this release.
      • setYear

        public void setYear​(int year)
        Set the year of this release.
        If the argument is outside the allowed range it is ignored.
        Parameters:
        year - the year to set.
      • totalTime

        public abstract int totalTime()
        Get the total time of this release.
        The implementation of this method is left to concrete subclasses.
        Returns:
        the duration of this release in seconds.
      • toString

        public java.lang.String toString()
        Get a textual representation of this release.

        The string representation of a release is "title-artist-year-totaltime" (without quotes and all names substituted with their respective values) unknown field are represented by the string "unknown" (without quotes).

        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation